home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 114 / macaddict114.cdr / Software / Graphics & Multimedia / DeBabelizerServerOSX.dmg / Packages / MediaRichShared.pkg / Contents / Resources / postinstall < prev    next >
Encoding:
Text File  |  2005-09-08  |  1.7 KB  |  79 lines

  1. #!/usr/bin/perl
  2.  
  3. use English;
  4.  
  5. sub backup_and_install_properties
  6. {
  7.     my $basepath = shift;
  8.     
  9.     # Does a properties file already exist?
  10.     if (-e $basepath)
  11.     {
  12.         # Back up the user's properties file
  13.         my $count = 1;
  14.         while (-e "${basepath}.bu${count}")
  15.         {
  16.             $count++;
  17.         }
  18.         system("mv ${basepath} ${basepath}.bu${count}");
  19.     }
  20.     
  21.     # Copy the new local.properties file into place (make it 'live')
  22.     system("cp ${basepath}.orig ${basepath}");
  23.     system("chmod g+rw ${basepath}");
  24. }
  25.  
  26. sub logit
  27. {
  28.     open F, ">>/tmp/postinstall.log";
  29.     print F $_[0] . "\n";
  30.     close F;
  31. }
  32.  
  33. my $isUpgrade = ($ARGV[4] eq "postupgrade");
  34.  
  35. # Define the stuff we need to set permissions on
  36. my @roots = (
  37.     "/Library/DeBabelizerServer/Shared",
  38.     );
  39. my @ourdirs = (
  40.     "/Library/DeBabelizerServer",
  41.     );
  42. my @sysdirs = (
  43.     "/",
  44.     "/Library",
  45.     );
  46.  
  47. # Set the mod flags on all our files
  48. foreach $r (@roots)
  49. {
  50.     system("chown -R $ENV{USER} \"$r\"");
  51.     system("chgrp -R mediarich \"$r\"");
  52.     system("chmod -R ug+w,o-w \"$r\"");
  53.     system("chmod -R a+rX \"$r\"");
  54. }
  55.  
  56. # Restore the permissions on the stuff the installer screwed up (Apple bug!!!)
  57. foreach $d (@ourdirs)
  58. {
  59.     system("chown $ENV{USER} \"$d\"");
  60.     system("chgrp  mediarich \"$d\"");
  61.     system("chmod 775 \"$d\"");
  62. }
  63.  
  64. open F, "</tmp/.__MR_PERMS__";
  65. my $line = readline F;
  66. my %perms = split(/,/, $line);
  67. close F;
  68. system("echo -n > /tmp/postinstall.out");
  69. foreach $d (@sysdirs)
  70. {
  71.     my @stats = split(/:/, $perms{$d});
  72.     system("chmod $stats[0] \"$d\"");
  73.     system("chown $stats[1] \"$d\"");
  74.     system("chgrp $stats[2] \"$d\"");
  75. }
  76.  
  77. backup_and_install_properties("/Library/DeBabelizerServer/Shared/Properties/global.properties");
  78. backup_and_install_properties("/Library/DeBabelizerServer/Shared/Properties/mime.properties");
  79.